@extends('home.parent')
@section('title','会员列表')
@section('head_js')
@endsection
@section('head_css')
<link rel="stylesheet" href="{{ asset('/css/dataTables.bootstrap.css') }}">
<link rel="stylesheet" href="{{ asset('/css/toggleButtonsMain.css') }}">
@endsection
@section('content')
  <div class="content-wrapper">
    <section class="content-header">
      <h1>
        会员列表
        <small></small>
      </h1>
      <ol class="breadcrumb">
        <li><a href="{{URL('admin')}}"><i class="fa fa-dashboard"></i> 首页</a></li>
        <li class="active">会员列表</li>
      </ol>
    </section>
    <section class="content">
      <div class="row">
        <div class="col-xs-12">
          <div class="box">
            <div class="box-header">
              <div class="form-inline pull-right">
                <fieldset>
                  <div class="input-group input-group-sm">
                    <span class="input-group-addon"><strong>用户名</strong></span>
                    <input type="text" class="form-control" id="user_name">
                  </div>
                  <div class="input-group input-group-sm">
                    <span class="input-group-addon"><strong>会员机构</strong></span>
                    <input type="text" class="form-control" id="company">
                  </div>
                  <div class="input-group input-group-sm">
                    <span class="input-group-addon"><strong>联系人</strong></span>
                    <input type="text" class="form-control" id="search_name">
                  </div>
                  <div class="input-group input-group-sm">
                    <span class="input-group-addon"><strong>手机号码</strong></span>
                    <input type="text" class="form-control" id="search_mobile">
                  </div>
                  <div class="input-group input-group-sm">
                    <span class="input-group-addon"><strong>所属合伙人</strong></span>
                    <input type="text" class="form-control" id="pName">
                  </div>
                  <div class="input-group input-group-sm">
                    <div class="input-group-btn">
                      <button type="button"  class="btn btn-primary" onclick="searchData()"><i class="fa fa-search"></i></button>
                    </div>
                  </div>
                </fieldset>
              </div>
              <div class="form-inline pull-left">
                <div class="input-group input-group-sm" style="margin-left: 20px;">
                  <div class="input-group-btn" >
                    <a href="{{ URL('admin/vip/create') }}" class="btn btn-info">新增会员</a>
                  </div>
                </div>
              </div>
            </div>
            <!-- /.box-header -->
            <div class="box-body">
              <table id="data_list" class="table table-bordered table-striped">
                <thead>
                  <tr>
                    <th>所属合伙人</th>
                      <th>创建者</th>
                    <th>用户名</th>
                    <th>地区</th>
                    <th>会员机构</th>
                    <th>行业</th>
                    <th>联系人</th>
                    <th>性别</th>
                    <th>联系方式</th>
                    <th>修改时间</th>
                    <th>创建时间</th>
                      <th>实名</th>
                      <th>雷达信息</th>
                    <th>状态</th>
                    <th>操作</th>
                  </tr>
                </thead>
                <tbody>
                </tbody>
                <tfoot>
                  <tr>
                    <th>所属合伙人</th>
                      <th>创建者</th>
                    <th>用户名</th>
                    <th>地区</th>
                    <th>会员机构</th>
                    <th>行业</th>
                    <th>联系人</th>
                    <th>性别</th>
                    <th>联系方式</th>
                    <th>修改时间</th>
                    <th>创建时间</th>
                      <th>实名</th>
                      <th>雷达信息</th>
                      <th>状态</th>
                    <th>操作</th>
                  </tr>
                </tfoot>
              </table>
            </div>
          </div>
        </div>
      </div>
    </section>
  </div>
<div class="modal fade" id="taldataform">
	<div class="modal-dialog">
		<div class="modal-content">
		<form id="dataform">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close">
				<span aria-hidden="true">&times;</span></button>
				<h4 class="modal-title">某某用户套餐详情</h4>
			</div>
			<div class="modal-body" style="max-height:300px;overflow:auto;padding:0 15px;">
				<table class="table table-bordered table-striped">
					<thead>
						<tr>
							<td width="100px">套餐名称</td>
							<td>套餐日期</td>
							<td>套餐金额</td>
							<td>套餐内容</td>
						</tr>
					</thead>
					<tbody>
						<tr>
							<td colspan="6">22</td>
						</tr>
					</tbody>
				</table>
			</div>
		</form>
		</div>
		<!-- /.modal-content -->
	</div>
	<!-- /.modal-dialog -->

</div>
  <style>
      #huoke table {
          border-collapse: collapse;
          color: #777;
          width: 100%;
      }

      #huoke table tr th, #huoke table tr td {
          padding: 10px;
          border: 1px solid #f8f8f8;
          white-space: nowrap
      }

      #huoke table tbody tr:hover {
          background: #f3f3f3;
      }

      #huoke table thead tr {
          background: #f0f0f0;
      }

      #huoke .more {
          text-align: center;
          padding: 10px 0;
      }

      #huoke .more span {
          cursor: pointer;
      }

      #huoke div button {
          padding-right: 20px;
          margin-right: 15px;
      }
  </style>
  <div id="huoke" style="display:none;color:#777;padding:10px 20px 0 20px;">
      <table>
          <thead>
          <tr>
              <td width="100px">数据类型</td>
              <td>当日私信数据</td>
              <td>7日内私信数据</td>
              <td>30天内私信数据</td>
              <td>总私信数</td>
              <td>当日获客数</td>
              <td>7日获客数</td>
              <td>30天内获客数</td>
              <td>总获客数</td>
          </tr>
          </thead>
          <tbody></tbody>
      </table>
      <div class="more"></div>
  </div>
  <style>
      #shoucang table {
          border-collapse: collapse;
          color: #777;
          width: 100%;
      }

      #shoucang table tr th, #shoucang table tr td {
          padding: 10px;
          border: 1px solid #f8f8f8;
          white-space: nowrap
      }

      #shoucang table tbody tr:hover {
          background: #f3f3f3;
      }

      #shoucang table thead tr {
          background: #f0f0f0;
      }

      #shoucang .more {
          text-align: center;
          padding: 10px 0;
      }

      #shoucang .more span {
          cursor: pointer;
      }

      #shoucang div button {
          padding-right: 20px;
          margin-right: 15px;
      }
  </style>
  <div id="shoucang" style="display:none;color:#777;padding:10px 20px 0 20px;">
      <table>
          <thead>
          <tr>
              <td>视频</td>
              <td>标题</td>
              <td>点赞数</td>
              <td>评论数</td>
              <td>转发数</td>
              <td>操作</td>
          </tr>
          </thead>
          <tbody></tbody>
      </table>
      <div class="more"></div>
  </div>
<div class="modal fade" id="viewDetails">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close">
				<span aria-hidden="true">&times;</span></button>
				<h4 class="modal-title">某某用户详情</h4>
			</div>
			<div class="modal-body" style="max-height:300px;overflow:auto;padding:10px 100px;"></div>
		</div>
	</div>
</div>
  {{--  这是雷达数据的--}}
  <style>
      #tableComment table {
          border-collapse: collapse;
          color: #777;
          width: 100%;
      }
      #tableComment table tr td {
          max-width: 300px;
          overflow:auto;
      }
      #tableComment table tr th, #tableComment table tr td {
          padding: 10px;
          border: 1px solid #f8f8f8;
          white-space: nowrap
      }

      #tableComment table tbody tr:hover {
          background: #f3f3f3;
      }

      #tableComment table thead tr {
          background: #f0f0f0;
      }

      #tableComment .more {
          text-align: center;
          padding: 10px 0;
      }

      #tableComment .more span {
          cursor: pointer;
      }

      #tableComment select {
          width:100px;
      }
      #tableComment div.input-group{
          float:right;
          max-width:180px;
          margin-bottom:8px;
      }
  </style>
  <div id="tableComment" style="display:none;color:#777;padding:10px 20px 0 20px;">
      <div class="input-group input-group-sm">
          <button class="btn btn-info btn-sm" onclick="searchAllData()">搜索</button>
      </div>
      <div class="input-group input-group-sm">
          <span class="input-group-addon"><strong>类型</strong></span>
          <select class="form-control" name="leidatype" id="leidatype">
              <option value="99">全部</option>
              <option value="1">账户雷达</option>
              <option value="2">视频雷达</option>
              <option value="3">广告雷达</option>
              <option value="4">直播雷达</option>
          </select>
      </div>
      <div class="input-group input-group-sm">
          <span class="input-group-addon"><strong>时间范围</strong></span>
          <select class="form-control" name="weekTime" id="weekTime">
              <option value="99">全部</option>
              <option value="1">当日内</option>
              <option value="2">一周内</option>
              <option value="3">一个月内</option>
          </select>
      </div>


      <table>
          <thead>
          <tr>
              <td>雷达类型</td>
              <td>视频/账户</td>
              <td>用户名</td>
              <td>昵称</td>
              <td >标题/简介</td>
              <td>关注/粉丝</td>
              <td>作品/获赞</td>
              <td>获赞数</td>
              <td>评论数</td>
              <td>分享数</td>
              <td>时间</td>
              <td>潜在客户</td>
          </tr>
          </thead>
          <tbody></tbody>
      </table>
      <div class="more"></div>
      <input type="hidden" name="kid">
      <input type="hidden" name="nextPage">
  </div>
  <div id="showQrcode" style="display:none;padding:20px;"></div>
@endsection
@section('foot_js')
<script src="{{ asset('/js/jquery.dataTables.min.js') }}"></script>
<script src="{{ asset('/js/dataTables.bootstrap.min.js') }}"></script>
<script src="{{ asset('/js/jquery.slimscroll.min.js') }}"></script>
<script src="{{ asset('/js/fastclick.js') }}"></script>
<script src="{{ asset('/js/tools.js') }}"></script>
<script>
var list_ajax;
$(function () {
  //提示信息
  var lang = puppet.langShow();
  //初始化表格
  list_ajax = $("#data_list").dataTable({
    language: lang, //提示信息
    autoWidth: false, //禁用自动调整列宽
    stripeClasses: ["odd", "even"], //为奇偶行加上样式，兼容不支持CSS伪类的场合
    processing: true, //隐藏加载提示,自行处理;
    serverSide: true, //启用服务器端分页
    searching: false, //禁用原生搜索
    //"sSearch": "搜索:",
    orderMulti: false, //启用多列排序
    order: [[0, 'desc']], //取消默认排序查询,否则复选框一列会出现小箭头
    renderer: "bootstrap", //渲染样式：Bootstrap和jquery-ui
    pagingType: "simple_numbers", //分页样式：simple,simple_numbers,full,full_numbers
    aLengthMenu : [10, 20, 50, 100], //更改显示记录数选项
    iDisplayLength:10,
    columnDefs: [
      {
        "targets": [1,2,3,4,5,6,7,8,9,10,11], //列的样式名
        "orderable": false    //包含上样式名‘nosort’的禁止排序
      },
    ],
    ajax: function (data, callback, settings) {
      //封装请求参数
      var param = {};
      param.limit = data.length; //页面显示记录条数，在页面显示每页显示多少项的时候
      param.start = data.start; //开始的记录序号
      param.page = (data.start / data.length) + 1; //当前页码
      param.order = data.order;
      param.user_name = $.trim($("#user_name").val());
      param.company = $.trim($("#company").val());
      param.name = $.trim($("#search_name").val());
      param.mobile = $.trim($("#search_mobile").val());
      param.pName = $.trim($("#pName").val());
      $.ajax({
        type: "POST",
        url: "{{ URL('admin/vip/list/ajax') }}",
        cache: false, //禁用缓存
        data: param, //传入组装的参数
        dataType: "json",
        success: function (result) {
          var returnData = {};
          returnData.draw = data.draw; //这里直接自行返回了draw计数器,应该由后台返回
          returnData.recordsTotal = result.total; //返回数据全部记录
          returnData.recordsFiltered = result.total; //后台不实现过滤功能，每次查询均视作全部结果
          returnData.data = result.data; //返回的数据列表
          callback(returnData);
        }
      });
    },
    //列表表头字段
    columns: [
      {"data": "pName"},
      {"data": "createname"},
      {"data": "user_name"},
      {"data": "city"},
      {"data": "company"},
      {"data": "indName"},
      {"data": "name"},
      {"data": "sex"},
      {"data": "mobile"},
      {"data": "update_time"},
      {"data": "create_time"},
      {"data": "realname"},
        {"data": "leida"},
      {"data": "status"},
      {"data": "operation"}
    ],
  }).api();
});
function actionList(id,status){
	var result;
	switch(status){
        case 0:
            result = layer.confirm('是否确认关闭', {
                btn: ['确认关闭', '再考虑一下'] //按钮
            }, function () {
                layer.msg('操作成功',{icon:1});
                xiugaivip(id, status);
            },function () {
                list_ajax.ajax.reload(null,false);
            });
            break;
        case 1:
            result = layer.confirm('是否确认开启', {
                btn: ['确认开启', '再考虑一下'] //按钮
            }, function () {
                layer.msg('操作成功',{icon:1});
                xiugaivip(id, status);
            },function () {
                list_ajax.ajax.reload(null,false);
            });
            break;
        case -1:
            result = layer.confirm('是否确认删除', {
                btn: ['确认删除', '再考虑一下'] //按钮
            }, function () {
                layer.msg('操作成功',{icon:1});
                xiugaivip(id, status);
            });
            break;
        default:
            result = layer.confirm('是否确认删除', {
                btn: ['确认删除', '再考虑一下'] //按钮
            }, function () {
                xiugaivip(id, status);
            });
            break;
    }
}
function xiugaivip(id, status) {
    var url = "{{URL('admin/vip/delete')}}";
    var data = {id:id,status:status};
    var result = puppet.myajax('post',url,data,false);
    if(result.code == true){
        layer.msg(result.message,{icon:5});
        return false;
    }else{
        list_ajax.ajax.reload(null,false);
    }
}
function searchData(){
  $("#data_list").dataTable().fnDraw(false);
    layer.msg('操作成功',{icon:6});
}
function mealList(kid,name){
	$('#taldataform').modal();
	$('#taldataform h4').html("<span style='font-weight:bold;'>"+name+"</span> 套餐详情");
	var data={kid:kid};
	var url = "{{URL('admin/vip/list/data')}}";
	var result = puppet.myajax('post',url,data,false);
	if(result.code == 1){
        layer.msg(result.message,{icon:5});
        return false;
	}else{
		$('#taldataform tbody').html(result.msg);
	}
}
function viewVip(kid,user_name){
	$('#viewDetails').modal();
	$('#viewDetails h4').html("<span style='font-weight:bold;'>"+name+"</span> 会员详情");
	var data={kid:kid};
	var url = "{{URL('admin/vip/view/info')}}";
	var result = puppet.myajax('post',url,data,false);
	if(result.code == 1){
        layer.msg(result.message,{icon:5});
        return false;
	}else{
		$('#viewDetails div.modal-body').html(result.msg);
	}
}
//获取会员雷达信息的方法
//获取会员雷达的页面数 搜索的数据
function showleida(kid,name) {
    layer.closeAll();
    vipleida(kid)
    $('#shoucang tbody').html("");
    showlayerArea("tableComment", name, "80%", "80%");
}
function vipleida(kid, page = 1) {
    var type =  $.trim($("#leidatype").val());
    var day = $.trim($("#weekTime").val());
    $.ajax({
        type: 'POST',
        url: "{{ URL('admin/vip/leida/data') }}",
        data: {kid: kid,type:type,day:day,page:page},
        dataType: 'json',
        success: function (r) {
            if (r.code == 1) {
                layer.msg(r.msg, {icon: 5});
                return false;
            }
            if (page == 1) {
                if (r.html == '') {
                    $('#tableComment tbody').html("<tr><td colspan=\"10\" style=\"text-align:center;\">无数据</td></tr>");
                } else {
                    $('#tableComment tbody').html(r.html);
                }
            } else if (page > 1) {
                $('#tableComment tbody').append(r.html);
            }
            if (r.nextPage == 0) {
                $('#tableComment .more').html("");
            } else {
                $('#tableComment .more').html("<span onclick=\"getMore(kid)\">点击加载更多</span>");
            }
            $('#tableComment input[name="kid"]').val(kid);
            $('#tableComment input[name="nextPage"]').val(r.nextPage);
        },
        error: function () {
            $('#tableComment tbody').html("<tr><td colspan=\"10\" style=\"text-align:center;\">无数据</td></tr>");
            layer.msg("网络错误", {icon: 5});
        }
    });
}

//加载下一页评论数据
function getMore() {
    var nextPage = $('#tableComment input[name="nextPage"]').val();
    var kid = $('#tableComment input[name="kid"]').val();
    if (nextPage != 0 && nextPage != '' && nextPage != undefined && !isNaN(nextPage)) {
        vipleida(kid, nextPage);
    }
}
//查询指定的数据
function searchAllData() {
    var kid = $('#tableComment input[name="kid"]').val();
    vipleida(kid);
}

function showhuokel(kid,name) {
    layer.closeAll();
    showhuokeall(kid,name)
    // $('#viphuoke').modal();
    // $('#huoke h4').html("<span style='font-weight:bold;'>"+name+"</span> 获取详情");
    $('#huoke tbody').html("");
    showlayerArea("huoke", name, "80%", "45%");
}
//查看对应会员获客数量的方法 kid 会员id  name 会员名称
function showhuokeall(kid,name){
    $.ajax({
        type: 'POST',
        url: "{{ URL('admin/vip/huoke/data') }}",
        data: {kid: kid},
        dataType: 'json',
        success: function (r) {
            if (r.code == 1) {
                $('#huoke tbody').html("<tr><td colspan=\"10\" style=\"text-align:center;\">无数据</td></tr>");
                layer.msg(r.msg, {icon: 5});
                return false;
            }else {
                $('#huoke tbody').html(r.msg);
            }
        },
        error: function () {
            $('#huoke tbody').html("<tr><td colspan=\"10\" style=\"text-align:center;\">无数据</td></tr>");
            layer.msg("网络错误", {icon: 5});
        }
    });
}
//收藏的方法
function showshoucang(kid,name) {
    layer.closeAll();
    shoucang(kid,name)
    $('#shoucang tbody').html("");
    showlayerArea("shoucang", name, "80%", "80%");
}
function shoucang(kid,name) {
    $.ajax({
        type: 'POST',
        url: "{{ URL('admin/vip/shoucang/data') }}",
        data: {kid: kid},
        dataType: 'json',
        success: function (r) {
            if (r.code == 1) {
                $('#shoucang tbody').html("<tr><td colspan=\"10\" style=\"text-align:center;\">无数据</td></tr>");
                layer.msg(r.msg, {icon: 5});
                return false;
            }else {
                $('#shoucang tbody').html(r.msg);
            }

        },
        error: function () {
            $('#shoucang tbody').html("<tr><td colspan=\"10\" style=\"text-align:center;\">无数据</td></tr>");
            layer.msg("网络错误", {icon: 5});
        }
    });
}
//获取下载链接
function copyvideo(itemid, id) {
    var itemid = itemid[0];
    var id = id;
    $.ajax({
        url: "{{URL('admin/vip/shoucang/getvideoUrl/ajax')}}",
        data: {itemid: itemid, id: id},
        type: "Post",
        dataType: "json",
        success: function () {
            layer.msg("操作成功", {icon: 6});
            dataListAjax();
        }, error: function (XMLHttpRequest, textStatus, errorThrown) {

        },
    });
}
//修改处理状态
function collectionqx(pid){

    var url = "{{URL('admin/company/account/mycollection/editStatus')}}";
    var data = {pid: pid,status:-1};
    var result = puppet.myajax('post', url, data, false);
    if (result.code == 0) {
        // $(obj).prop('type',status_text);
        layer.msg("操作成功",{icon:6,time:1000});
        dataListAjax();
    }else{
        layer.msg("操作失败",{icon:5,time:1000});
    }

}
</script>
@endsection